Remove messy Destroy test clean-up in TestPartialStateJoin#895
Remove messy Destroy test clean-up in TestPartialStateJoin#895MadLittleMods wants to merge 9 commits into
Destroy test clean-up in TestPartialStateJoin#895Conversation
All of this code has been obsoleted by #880
| defer cancel() | ||
| serverRoom := createTestRoom(t, server, alice.GetDefaultRoomVersion(t)) | ||
| psjResult := beginPartialStateJoin(t, server, serverRoom, alice) | ||
| defer psjResult.Destroy(t) |
There was a problem hiding this comment.
Removing all of the Destroy usage since it's no longer necessary
|
|
||
| // The caller is about to tear down the Complement homeserver. Leave the room, so | ||
| // that the homeserver under test stops sending it presence updates. | ||
| psj.Server.WithWaitForLeave( |
There was a problem hiding this comment.
#894 removes the WithWaitForLeave(...) part of Destroy(...)
This PR removes the need for finishing the waiters.
Which means Destroy(...) doesn't do anything anymore and we can remove it altogether. Less to think about.
| // wait is skipped when `user` had already left the room (per their own | ||
| // homeserver, so the action produces no new leave) or when this server isn't in | ||
| // the room (so the leave won't be federated to us). | ||
| func (s *server) WithWaitForLeave( |
There was a problem hiding this comment.
The WithWaitForLeave changes in the diff disappear once #894 is merged
This PR builds on that one so they are also included here for now.
…n` (#894) Follow-up to #880 which introduces a better way to avoid the test pollution and obsoletes the need for all of this cleanup logic. See the PR description there for a more complete context on why. `WithWaitForLeave` was originally introduced in this context: > Many of the faster joins test flakes are due to the homeserver under test failing to contact Complement homeservers after they have been torn down. When this happens, subsequent tests can fail if they use a Complement homeserver that happens to have the same `hostname:port` as one which the homeserver under test has previously marked as offline. > > *-- #626 But thanks to #880 we no longer use the same `hostname:port` for engineered homeservers anymore. And we can go even further with cleaning this up by removing the need for `Destroy(...)` altogether, see #895
…oin-cleanup2 Conflicts: tests/msc3902/federation_room_join_partial_state_test.go
| "to serve /state_ids response for event %s", queryParams["event_id"], | ||
| ) | ||
| } | ||
|
|
There was a problem hiding this comment.
This whole handler is the same as handleStateIdsRequests(...) except that it's serving an invalid response.
It's very tempting to dry this out but it's prior art ⏩
See #895 (comment) > Before Go 1.19, headings were identified implicitly by single-line paragraphs satisfying certain conditions, most notably the lack of any terminating punctuation. > > Gofmt reformats [lines treated as implicit headings](https://github.com/golang/proposal/blob/master/design/51082-godocfmt.md#headings) by earlier versions of Go to use # headings instead. If the reformatting is not appropriate—that is, if the line was not meant to be a heading—the easiest way to make it a paragraph is to introduce terminating punctuation such as a period or colon, or to break it into two lines. > > *-- https://go.dev/doc/comment#headings*
| select { | ||
| case <-sendResponseWaiter.Done(): | ||
| // Happy-path now that we're done waiting, continue serving the request now | ||
| case <-req.Context().Done(): |
There was a problem hiding this comment.
Instead of relying on Destroy to finish the waiter to allow this to continue, we instead rely on engineered homeserver being closed and all of the in-flight requests being cancelled (req.Context().Done()).
We still have a 60 second timeout like before.
This also fixes the goroutine panic that can happen when the waiter finishes after the test and t is used after the test finishes, see #894 (comment)
See #895 (comment) Here is what an LLM said: > `awaitPartialStateJoinCompletion` has the given user make a /members call, which blocks until the partial-state resync completes — a way to keep the homeserver from still trying to contact the Complement server after teardown. `beginPartialStateJoin` defaults `psjResult.User` to the joining user (alice), but in these two subtests alice leaves the room mid-test, so she couldn't be the one to make that /members call at cleanup time. Bob stays joined, so the tests swapped in bob: `psjResult.User = bob`. That's what the comment "At the end of the test, keep Bob in the room. Have him make a `/members` call..." was referring to. And that it's "now dead code, orphaned by your own cleanup"
Remove messy
Destroytest clean-up inTestPartialStateJoinFollow-up to #894 which removes another part of the clean-up code in this file and #880 which introduces a better way to avoid the test pollution and obsoletes the need for all of this cleanup logic. See the PR description there for a more complete context on why.
Destroy(...)was originally introduced in this context:But thanks to #880 we no longer use the same
hostname:portfor engineered homeservers anymore.Todo
WithWaitForLeavetest clean-up inTestPartialStateJoin#894 to mergePull Request Checklist